<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>后台登陆页</title>
<script type="text/javascript" src="<%=request.getContextPath() %>/extjs/ext-all.js"></script>
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/extjs/resources/css/ext-all.css"></link>
</head>
<script type="text/javascript">
	Ext.onReady(function(){
		Ext.QuickTips.init();
		Ext.form.Field.prototype.msgTarget = 'side';
		
		var btnSubmitClick=function(){
			if(form.getForm().isValid()) {
				var adminName = txtAdminName.getValue();
				var password  = txtPassword.getValue();
				 Ext.Ajax.request({
					url      : "login.do",
					waitMsg  :	"正在登录...",
					params   : {
						adminName:	adminName,
						password :	password,
					},
					success  :  function(resp,opts){
						var respText = Ext.JSON.decode(resp.responseText);  
						switch(respText.code) {
						case 0:
							Ext.Msg.alert("温馨提示","输入为空");
							break;
						case 1:
							Ext.Msg.alert("温馨提示","没有该管理员");
							break;
						case 2:
							Ext.Msg.alert("温馨提示","密码错误");
							break;
						case 3:
							window.location.href = "loginSuccess.do";
							break;
						default:
							break;
						}
					},
					failuer  : function(resp,opts){
						Ext.Msg.alert("温馨提示","访问失败");
					},
				}); 
				//form.submit();
			}
		};
		
		var btnResetClick=function(){
			form.getForm().reset();
		};
		
		var textSize = "font-size:20px";
		
		var btnSubmit = new Ext.Button({
			height      : 30,
			text   		: "提 交",
			//iconCls     : ""
			textStyle   : textSize,
			handler		: btnSubmitClick,
		});
		var btnReset = new Ext.Button({
			height      : 30,
			text   		: "重 置",
			//iconCls     : ""
			style		: textSize,
			handler		: btnResetClick
		});
		//登录名
		var txtAdminName= new Ext.form.TextField({
			width		: 300,
			height		: 40,
			allowBlank	: false,
			maxLength   : 50,
			name		: "adminname",
			fieldLabel  : "管理员",
			labelStyle	: textSize,
			labelWidht  : 20,
			labelAlign  : "right",
			blankText  	: "请输入管理员名称",
			emptyText   : "请输入管理员名称",
			maxLengthText: "输入管理员名不能超过50个字符"	,
			fieldStyle  : textSize,
		});
		//密码
		var txtPassword = new Ext.form.TextField({
			inputType	: "password",
			width		: 300,
			height		: 40,
			allowBlank :  false,
			maxLength   : 50,
			name		: "password",
			fieldLabel  : "密      码",
			labelStyle	: textSize,
			labelWidht  : 20,
			labelAlign  : "right",
			blankText	: "请输入管理员密码",
			emptyText   : "请输入管理员密码",
			maxLengthText: "输入管理员密码不能超过50个字符",
			fieldStyle  : textSize,
		});
		//
		var form = new Ext.form.FormPanel({
			url        	: 'login.do',
			labelWidth 	: 20,
			labelAlign 	: 'right',
			frame	   	: true,
			cls        	: 'loginform',
		    bodyStyle  	: 'padding:6px 0px 0px 15px;',
			items		: [txtAdminName, txtPassword],
			buttons		: [btnSubmit, btnReset],
			buttonAlign	: 'center',
			formStyle   : textSize,
		});
		
		//窗体
		var win = new Ext.Window({
			title		: '管理员登陆',
			iconCls		: "loginicon",
			plain		: true,
			width		: 400,
			height		: 200,
			resizable	: false,
			shadow		: true,
			modal		: true,
			closable	: false,
			animCollapse: true,
			items		: form,
		});
		
		win.show();
	});
</script>
<body background="<%=request.getContextPath() %>/images/loginbackground.jpg">
</body>
</html>